package com.enbatis.mybatisplugs.controller;

import com.enbatis.mybatisplugs.base.BaseController;
import com.enbatis.mybatisplugs.commons.sql.Wrapper;
import com.enbatis.mybatisplugs.commons.utils.ResultReturn;
import com.enbatis.mybatisplugs.entity.dto.LocationUserDTO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.enbatis.mybatisplugs.entity.LocationUser;
import com.enbatis.mybatisplugs.service.LocationUserService;


import java.util.List;

@RestController
@RequestMapping("v1/location_user")
public class LocationUserController extends BaseController {

@Autowired
private LocationUserService locationUserService;


    @PostMapping("/add")
    public ResultReturn<LocationUser> add(@RequestBody LocationUser locationUser){
        return  success(locationUserService.insert(locationUser));
    }


    @DeleteMapping("/delete")
    public ResultReturn<Integer> delete(@RequestParam("id") Long id){
        return success(locationUserService.deleteById(id));
    }


    @PutMapping("/{id}")
    public  ResultReturn<Integer> update(@PathVariable("id") Long id,@RequestBody LocationUser locationUser){
        locationUser.setId(id);
        return success(locationUserService.updateById(locationUser));
    }


    @GetMapping("/{id}")
    public ResultReturn<LocationUser> get(@PathVariable("id") Long id) {
        return success(locationUserService.getById(id));
    }


    @PostMapping("/list")
    public ResultReturn<List<LocationUserDTO>> getList(@RequestBody LocationUserDTO locationUser){
        return success(locationUserService.listLocation(locationUser));
    }


    @ApiOperation(value = "添加", notes = "添加一条数据")
    @PostMapping("/location_receive")
    public ResultReturn locationReceive(@RequestParam("data") String  json) {
        return success(locationUserService.locationReceive(json));
    }

}
